var app = getApp()
var db = wx.cloud.database()
Page({

    data: {

    },
    // 提交备忘录
    memo_submit: function (e) {
        let that = this;
        console.log(e)
        let title = e.detail.value.title;
        let content = e.detail.value.content;
        let addtime = that.data.moonth + "月" + that.data.nowday + "日" + "/周" + that.data.week;
        let rank = that.data.rank;
        db.collection('memo').add({
            data: {
                title: title,
                content: content,
                rank: rank,
                addtime: addtime,
                done: false
            }
        })
            .then(res => {
                console.log(res)
                if (res._id != "") {

                    wx.redirectTo({
                        url: '/pages/home/list/list',
                    })
                }
            })
    },
    // 
    radiochoose: function (e) {
        console.log(e.detail.value)
        this.setData({
            rank: e.detail.value
        })
    },

    onLoad: function (options) {
        let that = this;
        let winh = app.globalData.winH;
        let tabbar = app.globalData.tabbar;
        let date = new Date();
        let week = date.getDay(); //星期
        let nowday = date.getDate();
        let moonth = date.getMonth() + 1;
        let userinfo = wx.getStorageSync("userInfo");
        if (userinfo == "") {
            wx.navigateTo({
                url: '/pages/home/login/login',
            })
        }
        console.log(userinfo)
        that.setData({
            winh: winh,
            moonth: moonth,
            nowday: nowday,
            week: week,
            tabbar: tabbar,
            userinfo: userinfo
        })
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})